clear all; close all; clc;
q=10^(40/10);
T=1e-3;
fi=1e6;
fj=1e6;
f0=50e6;
Td=1/f0;
Tpn=1e-3/5110;
PNsize=fix(T/Tpn);
PN=sign(randn(1,PNsize));
Nd=fix(T/Td);
PSP=PN(1+mod(fix((0:Nd-1)*Td/Tpn),PNsize));
%plot(PSP);
A=sqrt(4*q*Td);
s=PSP.*cos(2*pi*fi*Td*(0:Nd-1));
JS=10^(60/10);
Aj=A*sqrt(JS);
for n=1:1000
y=Aj*cos(2*pi*fj*Td*(0:Nd-1))+A*s+randn(1,Nd);
I(n)=y*s';
end;
plot(I);

Q=20*log10(mean(I)/std(I))-3


S=abs(fft(y));
S=S/max(S);
%plot(20*log10(S))

h=20*log10(0);
S1 = S;
for k = 1:Nd
    if S1(k) > h
        S1(k) = 0;
    else
        S1(k) = S1(k);
    end
end
plot(20*log10(S1))

S2 = ifft(S1);

